package liuliu.throughwaring.ui.activity;

import android.widget.TextView;

import net.tsz.afinal.annotation.view.CodeNote;

import java.util.List;

import liuliu.custom.control.toolbar.TToolbar;
import liuliu.throughwaring.R;
import liuliu.throughwaring.base.BaseActivity;
import liuliu.throughwaring.model.CodeModel;
import liuliu.throughwaring.model.NoticeModel;

/**
 * Created by Administrator on 2016/3/24.
 */
public class ActivityViewNotice extends BaseActivity {
    @CodeNote(id = R.id.notice_author)
    TextView author;
    @CodeNote(id = R.id.notice_createtime)
    TextView createtime;
    @CodeNote(id = R.id.notice_fanwei)
    TextView fanwei;
    @CodeNote(id = R.id.view_notice_toolbar)
    TToolbar toolbar;
    @CodeNote(id = R.id.notice_value)
    TextView value;
    NoticeModel noticeModel = null;
    List<CodeModel> codeList;

    @Override
    public void initViews() {
        setContentView(R.layout.view_notice);
        noticeModel = (NoticeModel) getIntent().getSerializableExtra("NoticeModel");
        codeList = finalDb.findAllByWhere(CodeModel.class, "codeName='Code_Area'");
    }

    @Override
    public void initEvents() {
        toolbar.setLeftOnClick(new TToolbar.LeftOnClickListener() {
            @Override
            public void leftclick() {
                finish();
            }
        });
        if (null != noticeModel) {
            author.setText(noticeModel.getNoticeAuthor());
            createtime.setText(noticeModel.getNoticeCreateTime());
            fanwei.setText(getCodeyCompanyValue(noticeModel.getNoticeArea()));
            value.setText(noticeModel.getNoticeContent());
        }
    }

    private String getCodeyCompanyValue(String value) {
        for (int i = 0; i < codeList.size(); i++) {
            if (value.equals(codeList.get(i).getName())) {
                return codeList.get(i).getValue();//流动人员
            }
        }
        return "";
    }
}
